<template>
  <div>
    <!-- 系统初始化 -->
    <div class="head">
      <span>系统初始化</span>
    </div>
    <button @click="init">初始化</button>
  </div>
</template>

<script>
import { request } from "../../network/request";
export default {
  name: "",
  data() {
    return {};
  },
  methods: {
    init() {
      let r = confirm("是否要初始化系统？");
      if (r == true) {
        request({
          url: "http://118.31.51.131:8081/api/zsxt/xtcsh/csh",
          method: "post",
          params: {
            token: sessionStorage.getItem("token"),
          },
        }).then((value) => {
          console.log('初始化');
          alert("初始化成功");
        });
      }
    },
  },
  beforeCreate() {
    if (sessionStorage.getItem("token") == null) {
      this.$router.push("/login");
    } else {
      let token = sessionStorage.getItem("token");
      let length = sessionStorage.getItem("token").length;
      if (token[length - 6] == "0") {
        this.$router.replace("/login");
      }
    }
  },
  components: {},
};
</script>

<style scoped>
.head {
  height: 80px;
  border-bottom: 1px solid black;
}
.head span {
  font-size: 20px;
  line-height: 80px;
  margin-left: 25px;
}
button {
  position: absolute;
  left: calc(50% - 50px);
  top: calc(50% - 25px);
  width: 100px;
  height: 50px;
  border: none;
  outline: none;
  cursor: pointer;
  color: #fff;
  background-color: rgb(192, 51, 56);
}
button:active {
  opacity: 0.8;
}
</style>